package com.zhiyou.controller;

import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhiyou.model.UserModel;
import com.zhiyou.service.UserService;

@Controller
@RequestMapping("/user")
public class UserController {
	@Autowired
	UserService service;
	@RequestMapping(value="index")
	public String index(Model model){
		List<UserModel> list=service.queryUser();
     	model.addAttribute("list", list);
		return "user/index";
	}
	
	@ResponseBody
	@RequestMapping(value="tijiao",method=RequestMethod.POST)
	public Object tijiao(int[] danXuan,HttpServletRequest request){
		for (int i : danXuan) {
			System.out.println(i);
		}
		String pdir=request.getServletContext().getRealPath("/");
		System.out.println(pdir);
		HashMap map=new HashMap<>();
		map.put("pdir", pdir);
		return map;
	}
	
}
